<?php
namespace app\admin\logic;

class MistakeLogic extends BaseLogic {

    /**
     * 获取巡店查询条件
     */
    public function get_search_xd_maps($department,$start_time,$end_time){
        $maps = [];
        $maps[] = ['flag','like','xd_%'];

        if($department != '全部'){
            $maps[] = ['content','like',$department . '%'];
        }
        if(!empty($start_time)  && !empty($end_time)){
            $maps[] = ['now_date','between',[$start_time,$end_time]];
        }

        return $maps;
    }

    /**
     * 获取事项查询条件
     */
    public function get_search_sx_maps($username,$department,$start_time,$end_time,$flag){
        $maps = [];
        $maps[] = ['flag','like','sx_%'];

        if(!empty($username)){
            $u_maps = [];
            $u_maps[] = ['username','like','%' . $username . '%'];
            $openids_arr = model('user')->get_column($u_maps,'openid');
            $maps[] = ['openid','in',$openids_arr];
        }
        if($department != '全部'){
            $u_maps = [];
            $u_maps[] = ['department','like','%' . $department . '%'];
            $openids_arr = model('user')->get_column($u_maps,'openid');
            $maps[] = ['openid','in',$openids_arr];
        }
        if(!empty($start_time)  && !empty($end_time)){
            $maps[] = ['now_date','between',[$start_time,$end_time]];
        }
        if(!empty($flag)){
            $maps[] = ['flag','like',$flag . '%'];
        }
        return $maps;
    }
}